
coos.form.validate.stock = function(formId,islogin,message)
{
	
	coos.$id("subButton").disabled = true;
	var form = coos.$id(formId);
	if(form["chatRecord.content"].value.trim() == "" || form["chatRecord.content"].value == message)
	{
		alert("聊天内容不能为空，请填写后发表！");
		form["chatRecord.content"].focus();
		coos.$id("subButton").disabled = false;
		return false;
	}
	if(form["chatRecord.content"].value.trim().length > 100)
	{
		alert("聊天内容不能超过100个字，请修改后发表！");
		form["chatRecord.content"].focus();
		coos.$id("subButton").disabled = false;
		return false;
	}
	coos.cstock.stock.post(form);
	form["chatRecord.content"].focus();
	coos.$id("subButton").disabled = false;
	return false;
};

if(!coos.cstock)
{
	coos.cstock = function(){};
}

coos.cstock.stock = function(){};

coos.cstock.stock.get = function(url)
{
	coos.ajax.get(url,coos.cstock.stock.get.callback);
	return false;
};
coos.cstock.stock.get.callback = function(responseText)
{
	var obj = coos.$id("chatRecordList");
	obj.innerHTML = responseText;
	obj.scrollTop = obj.scrollHeight;
};

coos.cstock.stock.post = function(form)
{
	coos.ajax.post(form.action,coos.cstock.stock.post.callback,form,{form:form});
	return false;
};

coos.cstock.stock.post.callback = function(responseText,form)
{
	var rs = responseText.toJson();
	if(rs.state == "error")
	{
		alert(rs.message);
		form["chatRecord.content"].value = rs.content;
	}
	else
	{
		coos.cstock.stock.get(getStockUrl);
		form["chatRecord.content"].value = "";
	}
};



